home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
os2
/
adaptor.zip
/
ADAPT.ZIP
/
adaptor
/
examples
/
purdue
/
prob09.fcm
< prev
next >
Wrap
Text File
|
1993-06-26
|
4KB
|
172 lines
PROGRAM PROB09
C
C PROBLEM 9
C
C REFERENCE: PROBLEMS TO TEST PARALLEL AND VECTOR LANGUAGES
C CSD-TR 516, COMPUTER SCIENCE, PURDUE UNIVERSITY
C JOHN R. RICE, MAY 1, 1985
C
C REVISED BY JOHN R. RICE AND J. JING, OCT. 1, 1990
C
C
C *************************************************
C * Adapted for FORTRAN D benchmarking *
C * by T. HAUPT (haupt@sccs.npac.syr.edu) *
C * *
C * Northeast Parallel Architectures Center *
C * at Syracuse University, Syracuse, NY, USA *
C *************************************************
C
C
C VERSION SIMD/CM2-1.00
C ==================================================
C
INCLUDE '/usr/include/cm/paris-configuration-fort.h'
INTEGER KASES,NK,MK, NINT
PARAMETER (KASES=4)
INTEGER N(KASES),M(KASES)
cmf$ layout N(:SERIAL)
cmf$ layout M(:SERIAL)
DATA N /64,256,256,512/
DATA M /128,128,256,512/
PRINT *, 'PROBLEM 9 started'
DO 50 K = 1, KASES
C K=1
CALL CM_TIMER_CLEAR(0)
CALL CM_TIMER_START(0)
DO MANY=1,3
NK=N(K)
MK=M(K)
CALL DOIT(NK,MK,TSUMT,NINT)
ENDDO
CALL CM_TIMER_STOP(0)
PRINT 60, N(K),M(K)
60 FORMAT ('PROBLEM 9 WITH N,M =',I6,2X,I6)
PRINT *,'GIVES TSUMT =',TSUMT
PRINT *,'AFTER ',NINT,' ITERATIONS'
CALL CM_TIMER_PRINT(0)
50 CONTINUE
c STOP
END
SUBROUTINE DOIT(NK,MK,TSUMT,NINT)
INTEGER NK,MK
INTEGER NINT
REAL TSUMT,TOLER,ERROR
DATA TOLER /0.05/
REAL, ARRAY(NK,MK) :: U, T, LU, RU, ERRM
C
C intitialization
C
NINT=0
ERROR=1.0E10
!HPF$ INDEPENDENT, LOCAL_ACCESS
DO J = 1, MK
DO I = 1, NK
U(I,J) = I*(I+1)+FLOAT(J)/(J+1)
T(I,J) = 0.0
END DO
END DO
C
C update U
C
DO WHILE (ERROR.GT.TOLER)
NINT=NINT+1
LU = cshift (U,2,1)
c U(_,j+1) -> LU(_,j)
RU = cshift (U,2,-1)
c U(_,j-1) -> LU(_,j)
c update inner board
!HPF$ INDEPENDENT, LOCAL_ACCESS
DO J= 2, MK-1
DO I = 2, NK-1
T(I,J) = (U(I,J) + U(I+1,J) + U(I-1,J)
$ + LU(I,J) + LU(I+1,J) + LU(I-1,J)
$ + RU(I,J) + RU(I+1,J) + RU(I-1,J) ) / 9.
END DO
END DO
c RU(i-1,j) U(i-1,j) LU(i-1,j)
c RU(i ,j) U(i ,j) LU(i ,j)
c RU(i+1,j) U(i+1,j) LU(i+1,j)
c update left column
!HPF$ INDEPENDENT, LOCAL_ACCESS
DO J = 1, 1
DO I = 2, NK-1
T(I,J) = (U(I,J) + U(I+1,J) + U(I-1,J)
$ + LU(I,J) + LU(I+1,J) + LU(I-1,J) ) / 6.
END DO
END DO
c update right column
!HPF$ INDEPENDENT, LOCAL_ACCESS
DO J = MK, MK
DO I = 2, NK-1
T(I,J) = (U(I,J) + U(I+1,J) + U(I-1,J)
$ + RU(I,J) + RU(I+1,J) + RU(I-1,J) ) / 6.
END DO
END DO
c update top row
!HPF$ INDEPENDENT, LOCAL_ACCESS
DO J = 2, MK-1
T(1,J) = (U(1,J) + U(2,J) + LU(1,J)
$ + LU(2,J) + RU(1,J) + RU(2,J) ) / 6.
END DO
c update bottom row
!HPF$ INDEPENDENT, LOCAL_ACCESS
DO J = 2, MK-1
T(NK,J) = (U(NK,J) + U(NK-1,J) + LU(NK,J)
$ + LU(NK-1,J) + RU(NK,J) + RU(NK-1,J) ) / 6.
END DO
c update corners
T(1,1) = (U(1,1)+LU(1,1)+LU(2,1)+U(2,1)) / 4.
T(1,MK) = (U(1,MK)+RU(1,MK)+RU(2,MK)+U(2,MK)) / 4.
T(NK,1) = (U(NK,1)+LU(NK,1)+LU(NK-1,1)+U(NK-1,1)) / 4.
T(NK,MK) = (U(NK,MK)+RU(NK,MK)+RU(NK-1,MK)+U(NK-1,MK)) / 4.
WHERE (ABS(U).GT.0.001)
ERRM=ABS((U-T)/U)
ELSEWHERE
ERRM=ABS((U-T)/0.001)
ENDWHERE
ERROR=MAXVAL(ERRM)
U=T
c ERROR=0
END DO
TSUMT= SUM(U(1:NK,1:MK))
c RETURN
END